import 'package:flutter/material.dart';
import 'package:auto_route/auto_route.dart';
import 'package:juming_test/routes/app_router.gr.dart';

@RoutePage()
class TabScaffold extends StatelessWidget {
  const TabScaffold({super.key});

  @override
  Widget build(BuildContext context) {
    return AutoTabsRouter.tabBar(
      physics: const NeverScrollableScrollPhysics(),
      routes: [HomeRoute(), MessageRoute(), DiscoveryRoute(), MineRoute()],
      builder: (context, child, controller) {
        final tabsRouter = AutoTabsRouter.of(context);
        return Scaffold(
          body: child,
          bottomNavigationBar: BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            currentIndex: tabsRouter.activeIndex,
            onTap: tabsRouter.setActiveIndex,
            selectedItemColor: Colors.blue,
            unselectedItemColor: Colors.grey,
            items: [
              BottomNavigationBarItem(
                label: '首页',
                icon: Icon(Icons.home_filled),
              ),
              BottomNavigationBarItem(
                label: '消息',
                icon: Icon(Icons.message_rounded),
              ),
              BottomNavigationBarItem(
                label: '发现',
                icon: Icon(Icons.lightbulb_circle),
              ),
              BottomNavigationBarItem(
                label: '我的',
                icon: Icon(Icons.account_circle),
              ),
            ],
          ),
        );
      },
    );
    ;
  }
}
